//package top.roadvast.cors.interceptor;
//
//import org.springframework.http.HttpMethod;
//import org.springframework.http.HttpStatus;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//// 设置拦截器
//@Component
//public class CORSInterceptor implements HandlerInterceptor {
//
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
//        //放行哪些原始域
//        response.setHeader("Access-Control-Allow-Origin", "*");
//        //是否发送 Cookie
//        response.setHeader("Access-Control-Allow-Credentials", "true");
//        //放行哪些请求方式
//        response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS");
//
//        response.setHeader("Access-Control-Max-Age", "86400");
//        //放行哪些原始请求头部信息
//        response.setHeader("Access-Control-Allow-Headers", "*");
//
//
//        // 如果是OPTIONS则结束请求
//        if (HttpMethod.OPTIONS.toString().equals(request.getMethod())) {
//            response.setStatus(HttpStatus.NO_CONTENT.value());
//            return false;
//        }
//
//
//        return true;
//    }
//}
